form checkboxes different names each into multiple rows database [closed]
Posted
by
Darlene
on Programmers
See other posts from Programmers
or by Darlene
Published on 2012-11-03T04:13:19Z
Indexed on
2012/11/03
5:24 UTC
Read the original article
Hit count: 518
Hi i've been at this for hours and need help. Thanks in advice.
i have the following tables:
tblprequestion
quesid| ques
tblanswers
answerid|quesid | ans |date
This is my form: prequestion form
<?php
$con = mysql_connect("localhost","root","") or die ("Could not connect to DB Server");
$db_selected = mysql_select_db("nbtsdb", $con) or die("Could not locate the DB");
$query3= mysql_query("SELECT * FROM tblprequestions", $con)
or die("Cannot Access prequestions description from Server");
echo"<legend> Pre question :</legend>";
echo"<p></p>";
while($row = mysql_fetch_array($query3))
{
echo"<p>";
echo"<input type='checkbox' name='question".$row['quesid']."[]' value='yes'
/>";
echo"<label>".$row['ques']."</label> ";
echo"</p>";
}
echo"<p></p>";
?>
i would like to know how to get the values from the form for each question (total of 17) to submit into the database.
for example
tblprequestion
quesid| ques
1 Had a cold or fever in the last week?
2 Had minor outpaient surgery?
tblanswers
answerid|username |quesid | ans |date
1 lisa 1 yes 10/10/12
2 lisa 2 no 10/10/12
© Programmers or respective owner